﻿// 測試寫入excel的程式
using System;
using System.Text;
using System.IO;
using NPOI.HSSF.UserModel;
using NPOI.HPSF;
using NPOI.POIFS.FileSystem;

namespace SDD
{
    class Class1
    {
        public string filepath = @"C:\test.xls";
        public void mytest()
        {
            NPOIComFunction xls = new NPOIComFunction(filepath);
            HSSFSheet sheet1 = xls.Workbook.CreateSheet("s4");
            // 開始寫資料
            sheet1.CreateRow(0).CreateCell(0).SetCellValue("This is a Sample");
            int x = 1;
            for (int i = 1; i <= 15; i++)
            {
                HSSFRow row = sheet1.CreateRow(i);
                for (int j = 0; j < 15; j++)
                {
                    row.CreateCell(j).SetCellValue(x++);
                }
            }

            // 寫入實體檔案
            xls.WriteToFile();
        }
    }


}
